﻿var formatText = function (elCell, oRecord, oColumn, sData) {

    if (sData == "F") {
        elCell.innerHTML = "女";
    } else if (sData == "M") {
        elCell.innerHTML = "男";
    }
    else {
        elCell.innerHTML = sData;
    }
}
//新增
var fnCustomAdd = function () {
    parent.addTabs('新增联系人信息', '../Crm/Customer/EditCrmManager.aspx');
    parent.NeedRefreshPage = this;
}

//编辑
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var id = record.getData("ID");
    var cid = record.getData("CustomId");
    parent.addTabs('编辑联系人信息', '../Crm/Customer/EditCrmManager.aspx?r=' + Math.random() + '&entity=CrmLinkMan&cid=' + cid + '&id=' + id);
    parent.NeedRefreshPage = this;

}

//双击事件
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var id = record.getData("ID");
    var cid = record.getData("CustomId");
    parent.addTabs('编辑联系人信息', '../Crm/Customer/EditCrmManager.aspx?r=' + Math.random() + '&entity=CrmLinkMan&cid=' + cid + '&id=' + id);
    parent.NeedRefreshPage = this;
}
//删除
var fnCustomDelete = function () {
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    dl = [];
    for (var i = 0; i < list.length; i++) {
        //this.getRecordSet()._records[0]._oData["BarItem"]
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
            dl.push(list[i]._sId); //获取行ID；
        }
    }
    if (elist.length == 0) {
        var recordID = myDataTable.getSelectedRows()[0];
        record = myDataTable.getRecord(recordID);
        if (editpageFlag == 0) {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=CrmLinkMan&id=" + record.getData(const_entityID);
        } else {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&table=CrmLinkMan&id=" + record.getData(const_entityID);
        }
    }
    else {
        if (editpageFlag == 0) {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=CrmLinkMan&json=" + elist.join(",");
        }
        else {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&table=CrmLinkMan&json=" + elist.join(",");
        }
    }
    YAHOO.example.container.dialog3.show();
}

if (typeof ($) == "undefined") { //屏蔽右键
    parent.unContextMenu(document);
    /*$(document).ready(function () { 
    if (typeof (parent.unContextMenu) == "function") {
    parent.unContextMenu(document);
    }
    if (typeof (parent.parent.unContextMenu) == "function") {
    parent.parent.unContextMenu(document);
    }
    });*/
}
if (typeof (YAHOO) == "undefined") {
    parent.unContextMenu(document);
}